<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改广告</title>
<link href="${ctx }/style/css_member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx }/js/common.js"></script>
<script type="text/javascript" src="${ctx }/js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="${ctx }/js/ajaxupload.js"></script>

<script type="text/javascript">

$(document).ready(function(){

	new AjaxUpload("#uploadFile", {
		action : "${ctx }/fileUpload!uploadBackgroundImage.do",
		autoSubmit : true,
		name : "myFile",
		onSubmit : function(file, extension) {
			if (extension && /^(jpg|png|jpeg|gif)$/i.test(extension)) {
			} else {
				alert("你所选择的文件不受系统支持");
				return false;
			}
		},
		onComplete : function(file, response) {
			var img = document.createElement("img");
    	    img.style.width =  "355px";
    		img.style.height = "166px";
    		$("#picImage").val(response);
    		img.src = '${img_server}/UploadImages/'+response+'?tempid='+new Date().getTime();
    		switch_image(img);
		}
	});

	m2('m1_005','m1_005_06');
});

function clearAllNode(parentNode){
    while (parentNode.firstChild) {
      var oldNode = parentNode.removeChild(parentNode.firstChild);
       oldNode = null;
     }
}

function switch_image(img)
{
	clearAllNode(document.getElementById("photoTd"));
	document.getElementById("photoTd").appendChild(img);
}

function checkForm(){

	var title = $.trim($("#title").val());
	if (title == "") {
		$("#title").focus();
		alert("请填写广告主题。");
		return false;
	}

	var picImage = $("#picImage").val();
	if (picImage == "") {
		alert("请上传广告图片。");
		return false;
	}

	$("#advertiseForm").submit();
}

function gobackToAdvertiseList(){

	location.href = "${ctx}/advertise/advertisementAction!list.do";
}


</script>
</head>

<body>
<!-- 页面头部  -->
<jsp:include page="/commons/head_member.jsp"></jsp:include>

<form action="${ctx }/advertise/advertisementAction!modify.do" method="post" id="advertiseForm" name="advertiseForm" enctype="multipart/form-data">
<table width="960" align="center" border="0" cellspacing="0" cellpadding="0" class="tbl_add_border">
  <tr>
    <td width="14" height="37">&nbsp;</td>
    <td colspan="3" class="bt14A style25">修改广告</td>
    <td width="13">&nbsp;</td>
  </tr>
  <tr>
    <td class="bt14A" align="right"><span class="style15">*</span>广告主题：</td>
    <td class="bt14A"><input name="advertisement.title" type="text" size="40" id="title" value="${advertisement.title }"></td>
    <td width="355" rowspan="4" valign="top" class="slet"><div align="center">
      <table width="355" height="166" border="0" cellpadding="0" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#CCCCCC">
        <tr>
          <td bgcolor="#FFFFFF" id="photoTd">
           		<img src="${advertisement.imagepath }" border="0"  width="355" height="166" >
          </td>
        </tr>
      </table>
      </div></td>
  </tr>
  <tr>
    <td class="bt14A" align="right"><span class="style15">*</span>广告图片：</td>
    <td class="bt14A"><span id="uploadFile" style="color: #0000FF">上传</span></td>
  </tr>
  <tr>
    <td class="bt14A" align="right"><span class="style15">*</span>链接地址：</td>
    <td class="bt14A"><input name="advertisement.linkAddress" type="text" size="50" value="${advertisement.linkAddress }"></td>
  </tr>
   <tr>
    <td class="bt14A" align="right"><span class="style15">*</span>所属频道：</td>
    <td class="bt14A">
    	<select name="advertisement.channelID">
    		<option value="">请选择</option>
			<s:iterator value="#request.advertisementMap" id="column">
				   <option value='<s:property value="key"/>' <s:if test="advertisement.channelID == key">selected</s:if>><s:property value="value"/></option>
			</s:iterator>    		
    	</select>
    </td>
  </tr>
  <tr>
    <td width="127" class="nw12a">
        <!-- 隐藏域 begin -->
        	<input type="hidden" name="picImage" id="picImage" value="${advertisement.imageInfo.id }"/>
        	<input type="hidden" name="advertisement.id" id="advertisement_id" value="${advertisement.id }"/>
        <!-- 隐藏域 end -->
    </td>
    <td width="421" class="nw12a">
        <input type="button" value="保存"  class="btn_2"  onclick="checkForm()">
       	<input type="button" value="返回广告列表" class="btn_6"  onclick="gobackToAdvertiseList()">
    </td>
  </tr>
  <tr><td height="30"></td></tr>
</table>
</form>

<jsp:include page="/commons/foot_member.jsp"></jsp:include>

</body>
</html>